home *** CD-ROM | disk | FTP | other *** search
- Path: drivel.ics.uci.edu!news
- From: Doug Semler <drsemler@uci.edu>
- Newsgroups: comp.lang.c++
- Subject: Template help...
- Date: Mon, 22 Jan 1996 06:31:25 -0800
- Organization: University of California, Irvine
- Message-ID: <31039FBD.167EB0E7@uci.edu>
- NNTP-Posting-Host: clownfish.ics.uci.edu
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b4 (X11; I; SunOS 4.1.4 sun4m)
-
- Question about templating:
-
- I have a template
-
- template
- < class element >
- struct temp {
- ... // elements in template, ctors, etc. implementing linked list
- };
-
- and define my types such:
-
- typedef struct a_block *a;
- typedef <a> a_temp;
- typedef a_temp a_list;
-
- typedef struct b_block *b;
- typedef <b> b_temp;
- typedef b_temp b_list;
-
- a_list A;
- b_list B;
-
- My problem is this...I want to find elements from list A based on a
- character string, and list B based on an integer. The code is the
- same (traverse list until found) and I would like to be able to say
- A->find_element(char *id); or
- B->find_element(int i);
-
- (I have overloaded == function for char * types BTW)
- Is it possible?
-
- --
- Doug Semler | drsemler@uci.edu
- University of California, Irvine | Send all flames to /dev/null
- Information and Computer Science | Of course these are *MY* opinions
- http://www.ics.uci.edu/~dsemler | When in doubt, RTFM!
-